<template>
	<view class="resourceList">
		<uni-row style="margin-top: 8rpx;margin-bottom: 20rpx;">
			<uni-col :span="2" style="padding-top: 7rpx;">
				<uni-icons type="list" size="32"></uni-icons>
			</uni-col>
			<uni-col :span="18" style="padding-left: 20rpx;">
				<uni-easyinput style="background-color: #fff;" suffixIcon="search" v-model="queryParams.number"
					placeholder="质检单号" @iconClick="queryClick"></uni-easyinput>
			</uni-col>
			<uni-col :span="4" style="padding-left: 8rpx;padding-top: 7rpx;">
				<uni-icons type="scan" size="32"></uni-icons>
			</uni-col>
		</uni-row>
		<view v-for="(item,index) in reportQualityList" style="margin-top: 10rpx;">
			<uni-row class="resourceList-uni-row">
				<text style="font-size: 18px;font-weight:bold;">
					质检单:&nbsp;&nbsp;&nbsp;{{item.number}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					质检时间:&nbsp;&nbsp;&nbsp;{{item.checkTime}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					质检员:&nbsp;&nbsp;&nbsp;{{item.checkUserName}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					报工单:&nbsp;&nbsp;&nbsp;{{item.reportNumber}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					产品:&nbsp;&nbsp;&nbsp;{{item.materialName}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					工序:&nbsp;&nbsp;&nbsp;{{item.processName}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<uni-col :span="24">
					<text class="resourceList-text">
						检测数:&nbsp;&nbsp;&nbsp;{{item.quantity}}
					</text>
				</uni-col>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<text class="resourceList-text">
					合格数:&nbsp;&nbsp;&nbsp;{{item.qualifiedQuantity}}
				</text>
			</uni-row>
			<uni-row class="resourceList-uni-row">
				<uni-col :span="18">
					<text class="resourceList-text">
						备注:&nbsp;&nbsp;&nbsp;{{item.remark}}
					</text>
				</uni-col>
				<uni-col :span="6">
					<button style="padding: 0rpx; height: 57rpx;width: 120rpx;" plain="true" size="mini" type="primary"
						@click="addReportQuality(item.id)">
						<text style="font-size: 4;">详情</text>
					</button>
				</uni-col>
			</uni-row>
		</view>
		<uni-load-more :status="loadStatus"  />
		<reportQualityForm ref="reportQualityForm"> </reportQualityForm>
	</view>

</template>

<script>
	import {
		addReportQuality,
		listReportQuality,
		getReportQuality
	} from "@/api/quality/reportQuality";
	import {
		getUserProfile
	} from "@/api/system/user"
	import {
		getDicts
	} from "@/api/system/dict/data";
	import reportQualityForm from "@/pages/quality/reportQuality/form.vue";
	export default {
		components: {
			reportQualityForm
		},
		data() {
			return {
				queryParams: {
					pageSize: 5,
					pageNum: 1
				},
				//报工质检单列表
				reportQualityList: [],
				user: {},
				loadStatus: "more"
			}
		},
		created() {
			this.getList();
		},
		onReachBottom() {
			this.clickLoadMore()
		},
		methods: {
			/** 查询报工单列表 */
			getList() {
				this.queryParams.checkUserId = this.user.userId
				listReportQuality(this.queryParams).then(reportResponse => {
					let total =reportResponse.total;
					let list = reportResponse.rows;
					//已查询出来的和新查询的 大于等于total总页数，表示no-more
					if (list.length+this.reportQualityList.length >=total) {
						this.loadStatus = "no-more"
					} else {
						this.loadStatus = "more"
					}
					if (this.reportQualityList.length > 0) {
						this.reportQualityList = this.reportQualityList.concat(list)
					} else {
						this.reportQualityList = list;
					}

				})
			},
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data
				})
			},
			//点击质检详情
			addReportQuality(id) {
				this.$refs.reportQualityForm.qualityInfo(id);
			},
			queryClick() {
				this.queryParams.pageNum = 1
				this.reportQualityList = []
				this.getList();
			},
			clickLoadMore() {
				if (this.loadStatus === "no-more") {
					return;
				}
				this.loadStatus = "loading"
				this.queryParams.pageNum += 1;
				this.getList();
			}
		},
	}
</script>

<style>
	.resourceList-uni-row {
		margin-bottom: 8rpx;
	}

	.resourceList-text {
		font-size: 16px;
	}

	.resourceList {
		margin-left: 10px;

	}
</style>
